package com.example.retrofit_test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.example.retrofit_test.RetrofitHttp.HttpHelper;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MainActivity extends AppCompatActivity {

    /*public static void start(Activity activity){
        Intent intent = new Intent(activity,MainActivity.class);
        activity.startActivity(intent);
    }*/

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView button = (TextView) findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                /*Main2Activity.start(MainActivity.this);
                Main2Activity.start1(MainActivity.this);
                Main2Activity.start2(MainActivity.this);
                Main2Activity.start3(MainActivity.this);
                Main2Activity.start4(MainActivity.this);
                Main2Activity.start5(MainActivity.this);
                Main2Activity.start6(MainActivity.this);
                Main2Activity.start7(MainActivity.this);
                Main2Activity.start8(MainActivity.this);*/


                Intent intent = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent1 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent2 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent3 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent4 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent5 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent6 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent7 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                Intent intent8 = new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
            }
        });

        /* ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        activityManager.getMemoryInfo(memoryInfo);

        long availMem = memoryInfo.availMem/1024/1024;

        button.setText(availMem+"MB");
*/
    }

    private void test(){
        Call<String> call = HttpHelper.getStringService().getResult("","");
        call.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                System.out.println("response.isSuccessful():"+response.isSuccessful());
                System.out.println("response.body().name:"+ response.body());
                System.out.println("response.body().pwd:"+ response.body());

                System.out.println("response.message():"+ response.message());

            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                System.out.println(t.getMessage());
            }
        });
    }
}
